using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_PortableItemPanel : UIBaseNode
    {
        #region Template Generate,don't modify

        protected class UIB_UIN_PortableItemPanel
        {
            #region ObjectBinding Generate

            public ExText itemName { protected set; get; }
            public ExText itemDesc { protected set; get; }
            public ExText itemType { protected set; get; }
            public ExText itemNum { protected set; get; }
            public GameObject commonItem { protected set; get; }
            public ExText itemEffect { protected set; get; }

            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<ExText>("itemName", out var __tbv0);
                itemName = __tbv0;
                __binding.TryGetVariableValue<ExText>("itemDesc", out var __tbv1);
                itemDesc = __tbv1;
                __binding.TryGetVariableValue<ExText>("itemType", out var __tbv2);
                itemType = __tbv2;
                __binding.TryGetVariableValue<ExText>("itemNum", out var __tbv3);
                itemNum = __tbv3;
                __binding.TryGetVariableValue<GameObject>("commonItem", out var __tbv4);
                commonItem = __tbv4;
                __binding.TryGetVariableValue<ExText>("itemEffect", out var __tbv5);
                itemEffect = __tbv5;
            }

            #endregion ObjectBinding Generate
        }

        #endregion Template Generate,don't modify

        #region Exposed

        public void Refresh(ItemData itemData)
        {
            ui.itemName.text = itemData.cfgData.Name;
            ui.itemDesc.text = itemData.cfgData.Describe;
            ui.itemType.text = itemData.cfgData.TypeDesc;
            ui.itemNum.text = itemData.num.ToString();
            ui.itemEffect.text = itemData.cfgData.EffectTxt;
            _item.Show(itemData.cid, itemData.num);
        }

        #endregion

        #region Override

        protected UIB_UIN_PortableItemPanel ui { get; set; }

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_PortableItemPanel();
            ui.InitBinding(csObjBind);
        }

        protected override void OnInit()
        {
            _item = InitChildNode<UIN_OneItem>(ui.commonItem);
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        protected override void OnDispose()
        {
        }

        #endregion

        #region Field

        private UIN_OneItem _item;

        #endregion
    }
}